#include<bits/stdc++.h>
#define ll long long
#define for1(i,a,b) for(ll i=a;i<=b;i++)
using namespace std;
inline ll re()
{
    ll s=0,f=1; char c=getchar();
    while(!isdigit(c)) {if(c=='-')f=-1;c=getchar();}
    while(isdigit(c)) {s=s*10+c-'0';c=getchar();}
    return f*s;
}
inline void wr(ll x)
{
    if(x<0) {putchar('-');wr(-x);return;}
    if(x>9) wr(x/10);
    putchar(x%10+'0');
}
const ll N=1e6+10;
struct node{
    ll d,v,a;
}f[N];
bool cmp(node n1,node n2)
{
    return n1.a>n2.a;
}
struct Lft{
    ll bh,l,r;
}lft[N];
bool cmp1(Lft n1,Lft n2)
{
    if(n1.l==n2.l) return n1.r<n2.r;
    return n1.l<n2.l;
}
struct Rgt{
    ll bh,l,r;
}rgt[N];
bool cmp2(Rgt n1,Rgt n2)
{
    if(n1.r==n2.r) return n1.l<n2.l;
    return n1.r<n2.r;
}
bool vis[N];
ll T,n,m,L,V,p[N],ci,rec[N],ri;
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout); 
    T=re();
    while(T--)
    {
        memset(vis,0,sizeof(vis));
        ci=0,ri=0;
        n=re(),m=re(),L=re(),V=re();
        bool g=0,gg=0;
        for1(i,1,n)
        {
            f[i].d=re(),f[i].v=re(),f[i].a=re();
            if(f[i].a<0) g=1;
            // cout<<g<<endl;
        }
        for1(i,1,m) p[i]=re();
        p[m+1]=4e18;
        // if(!g)
        // {
        //     ll cnt=0;
        //     for1(i,1,n)
        //     {
        //         if(f[i].d>p[m]) continue;
        //         if(2*f[i].a*(p[m]-f[i].d)+f[i].v*f[i].v>V*V) cnt++;
        //     }
        //     cout<<cnt<<" ";
        //     if(cnt) cout<<m-1<<endl;
        //     else cout<<m<<endl;
        //     continue;
        // }
        // else
        {
            sort(f+1,f+n+1,cmp);
            ll cnt=0,ma=-4e18;
            for1(i,1,n)
            {
                if(f[i].a>0)
                {
                    if(f[i].d>p[m]) continue;
                    if(2*f[i].a*(p[m]-f[i].d)+f[i].v*f[i].v>V*V)
                    {
                        cnt++;
                    }
                    ll x;
                    if((ll)(V*V-f[i].v*f[i].v)/(2*f[i].a)>L) continue;
                    else
                    if((V*V-f[i].v*f[i].v)%(2*f[i].a)==0)
                    {
                        x=f[i].d+(V*V-f[i].v*f[i].v)/(2*f[i].a)+1;
                    }
                    else
                    {
                        x=f[i].d+(V*V-f[i].v*f[i].v)/(2*f[i].a);
                    }
                    ma=max(ma,x);
                }
                else if(f[i].a==0)
                {
                    if(f[i].d>p[m]) continue;
                    if(f[i].v>V)
                    {
                        cnt++;
                        ma=max(ma,f[i].d);
                    }
                }
                else
                {
                    if(f[i].v<=V) continue;
                    ll x;
                    if((f[i].v*f[i].v-V*V)%(-2*f[i].a)==0)
                    {
                        x=min(L,f[i].d+(f[i].v*f[i].v-V*V)/(-2*f[i].a)-1);
                    }
                    else
                    {
                        x=min(L,f[i].d+(f[i].v*f[i].v-V*V)/(-2*f[i].a));
                    }
                    // cout<<x<<endl;
                    ll w=upper_bound(p+1,p+m+2,x)-p-1;
                    if(p[w]<f[i].d) continue;
                    cnt++; ci++;
                    lft[ci].bh=rgt[ci].bh=ci;
                    lft[ci].l=rgt[ci].l=f[i].d;
                    lft[ci].r=rgt[ci].r=x;
                }
            }
            cout<<cnt<<" ";
            sort(lft+1,lft+ci+1,cmp1);
            sort(rgt+1,rgt+ci+1,cmp2);
            // for1(i,1,ci) cout<<lft[i].bh<<" "<<lft[i].l<<" "<<lft[i].r<<endl;
            // cout<<endl;
            // for1(i,1,ci) cout<<rgt[i].bh<<" "<<rgt[i].l<<" "<<rgt[i].r<<endl;
            // cout<<endl;
            ll j=1;
            for1(i,1,ci)
            {
                if(vis[rgt[i].bh]) continue;
                ll w=upper_bound(p+1,p+m+2,rgt[i].r)-p-1;
                rec[++ri]=p[w];
                // cout<<p[w]<<endl;
                while(lft[j].l<=p[w]) vis[lft[j].bh]=1,j++;
            }
            if(rec[ri]>=ma) cout<<m-ri<<endl;
            else cout<<m-ri-1<<endl;
        }
    }
    return 0;
}
/*
1
5 5 15 3
0 3 0
12 4 0
1 1 4
5 5 -2
6 4 -4
2 5 8 9 15
*/